refactor: parameterize mentor-duty label#2147
Conversation
Up to standards ✅🟢 Issues
|
exploreriii
left a comment
There was a problem hiding this comment.
Hi @mitul001 thanks for this but please check your submission it needs to be DCO+GPG key signed as per the issue description
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdded a configurable Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📋 Issue PlannerBuilt with CodeRabbit's Coding Plans for faster development and fewer bugs. View plan used: ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 995680c6-2154-4856-8706-99475ef7984e
📒 Files selected for processing (1)
.github/scripts/bot-assignment-check.sh
7c5a47d to
2627323
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: e137dbe4-9381-45f1-bb15-6869dd96b345
📒 Files selected for processing (2)
.github/scripts/bot-assignment-check.sh.github/workflows/bot-assignment-check.yml
2627323 to
1cc088e
Compare
09243c5 to
c6b15bb
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/scripts/bot-assignment-check.sh (1)
57-60:⚠️ Potential issue | 🔴 Critical
gh api --jq --argis invalid here and can silently undercount assignments.Line 57 passes
--argas if it were agh apiflag. On failure,|| echo 0converts the error into a zero count, which can incorrectly allow extra triage assignments.Proposed fix
- gh api "repos/${REPO}/issues?per_page=100&page=1" \ - -f assignee="${ASSIGNEE}" \ - -f state=open \ - --jq --arg mentor_label "$MENTOR_LABEL" '.[] - | select(.pull_request == null) - | select(any(.labels[]; .name == $mentor_label) | not) - | .number' | grep -c . || echo 0 + gh api "repos/${REPO}/issues?per_page=100&page=1" \ + -f assignee="${ASSIGNEE}" \ + -f state=open \ + | jq -r --arg mentor_label "$MENTOR_LABEL" ' + [.[] + | select(.pull_request == null) + | select(any((.labels // [])[]; .name == $mentor_label) | not) + ] | length + '#!/bin/bash set -euo pipefail echo "== gh api supported flags ==" gh api --help | rg -n -- '--jq|--arg' || true echo echo "== reproduce option parsing behavior ==" set +e gh api repos/cli/cli/issues --jq --arg mentor_label test '.[].number' 2>&1 | sed -n '1,6p' status=$? set -e echo "exit_status=${status}"
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: f4858ebd-7b64-4c80-a5bf-4581da4f6808
📒 Files selected for processing (2)
.github/scripts/bot-assignment-check.sh.github/workflows/bot-assignment-check.yml
9c83ce6 to
90c88e0
Compare
|
Hi @mitul001, rebase or click the update branch button in ui |
90c88e0 to
f6208af
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
.github/scripts/bot-assignment-check.sh (1)
54-60:⚠️ Potential issue | 🔴 Critical
gh api --jqstill doesn't accept--arg; the triage count is silently zero.Despite the previous review being marked as addressed, the current code still passes
--arg mentor_label "$MENTOR_LABEL"directly as arguments togh api --jq. Thegh api --jqflag consumes only a single jq expression string and does not forward further flags tojq. At runtime this will fail withunknown flag: --arg(or treat--argas the filter and fail to parse), and because the whole pipeline is guarded by|| echo 0, the failure is masked andassignments_countsilently returns0for every triage user — meaning mentors bypass the limit entirely.Run through
jqexplicitly so--argis honored:🛠️ Proposed fix
- gh api "repos/${REPO}/issues?per_page=100&page=1" \ - -f assignee="${ASSIGNEE}" \ - -f state=open \ - --jq --arg mentor_label "$MENTOR_LABEL" '.[] - | select(.pull_request == null) - | select(any(.labels[]; .name == $mentor_label) | not) - | .number' | grep -c . || echo 0 + gh api "repos/${REPO}/issues?per_page=100&page=1" \ + -f assignee="${ASSIGNEE}" \ + -f state=open \ + | jq -r --arg mentor_label "$MENTOR_LABEL" ' + .[] + | select(.pull_request == null) + | select(any((.labels // [])[]; .name == $mentor_label) | not) + | .number + ' | grep -c . || echo 0Also worth decoupling the
|| echo 0fromgrep -c(e.g., capture the pipeline status separately) so genuine API errors don't continue to be silently swallowed.#!/bin/bash # Confirm gh api --jq does not accept --arg gh api --help 2>&1 | rg -nC2 -- '--jq|--arg' || true
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: ee22a307-1041-426e-a29d-57cd4d6acd49
📒 Files selected for processing (2)
.github/scripts/bot-assignment-check.sh.github/workflows/bot-assignment-check.yml
Signed-off-by: mitul001 <mitulp994@gmail.com>
f6208af to
ee07f7d
Compare
exploreriii
left a comment
There was a problem hiding this comment.
@mitul001 when you force push, you reset the review status, recommend to avoid that
Hi @exploreriii, thank you for the feedback and for approving the PR! My apologies for the force-push. I was fixing the GPG signature and indentation issues, but I'll make sure to avoid resetting the review status with force-pushes in future submissions. Thanks for your patience! |
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
.github/scripts/bot-assignment-check.sh (1)
54-60:⚠️ Potential issue | 🔴 CriticalFix
gh api --arg; the triage count can silently become zero.Line 57 still passes jq’s
--argflag togh api, which does not support it. Because the pipeline ends with|| echo 0, this can mask the CLI failure and allow over-assignment for triage users.Proposed fix
- gh api "repos/${REPO}/issues?per_page=100&page=1" \ - -f assignee="${ASSIGNEE}" \ - -f state=open \ - --jq --arg mentor_label "$MENTOR_LABEL" '.[] - | select(.pull_request == null) - | select(any(.labels[]; .name == $mentor_label) | not) - | .number' | grep -c . || echo 0 + gh api "repos/${REPO}/issues?per_page=100&page=1" \ + -f assignee="${ASSIGNEE}" \ + -f state=open \ + | jq --arg mentor_label "$MENTOR_LABEL" '[ + .[] + | select(.pull_request == null) + | select(any((.labels // [])[]; .name == $mentor_label) | not) + ] | length'Verify the runner has the expected CLI behavior and
jqavailable:#!/bin/bash set -euo pipefail echo "== gh version ==" gh --version | sed -n '1p' echo "== gh api jq-related flags ==" gh api --help | rg -n -- '--jq|--arg' || true echo "== jq availability ==" command -v jq jq --version
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3a697c3f-e101-4afd-a402-f1d54daa4cf0
📒 Files selected for processing (2)
.github/scripts/bot-assignment-check.sh.github/workflows/bot-assignment-check.yml
Signed-off-by: mitul001 <mitulp994@gmail.com> Co-authored-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
Signed-off-by: mitul001 <mitulp994@gmail.com> Co-authored-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
Signed-off-by: mitul001 <mitulp994@gmail.com> Co-authored-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
Fixes #2128